<!--  -->
<template>
  <div>
      <div class="hotcity">
          <div class="hotcity_header">
              <i></i>
              <span>热门目的地推荐</span>
              <i></i>
          </div>
         <div class="nav_list" id="searchBar">
                  <div class="nev">
            <div v-for="(item, index) in tags" :key="index" @click="getidx(index)">
                {{item.name}}
            </div>
          </div>
          <div class="host_list" >
              <ul>
                <div class="moren" id="morens" v-show="none">
                  <li>热门</li>
                  <li>内蒙</li>
                  <li>新疆</li>
                  <li>西北</li>
                  <li>贵州</li>
                  <li>广西</li>
                  <li>四川</li>
                  <li>西藏</li>
                  <li>云南</li>
                  <li>秦晋</li>
                  <li>华南</li>
                  <li>华北</li>
                  <li>华中</li>
                  <li>华东</li>
                  <li>更多</li>
                </div>
                <li  v-for="(val, idx) in itemddata" :key="idx" >
                    {{val.name}}
                </li>
              </ul>
          </div>
           
         </div>
         <div class="host_concat" v-for="(item, index) in products" :key="index">
             <!-- {{item.thumb}} -->
             <div class="concat_img">
                 <img :src="item.thumb" alt="">
                <div class="postion_top">
                    {{item.product_type}} | {{item.place_label}}
                </div>
                <div class="postion_bottom">
                    <span class="s1">{{item.price_label}}</span>
                    <span class="s2">{{item.days}}</span>
                </div>
             </div>
             <div class="concat_text">
                 <div class="text1">{{item.product_name}}</div>
                 <div class="text2">
                     <span>{{item.product_cat}}</span>
                    {{item.sub_name}}
                 </div>
             </div>
         </div>
      </div>
  </div>
</template>

<script>
export default {
  props: ["tags"],
  data() {
    return {
      products: "",
      itemddata:"",
      none:true,
      // getidx:""
    };
  },
  mounted() {
    this.$http.get("/api/list.json").then(res => {
      console.log(this.tags);
      this.products = res.data.data.products;
    });
    window.addEventListener("scroll", this.handleScroll);
  },
  methods: {
      getidx(idx){
      console.log(this.tags[idx]);
       this.itemddata=this.tags[idx].items;
       this.none=false;
      },
    handleScroll() {
      var scrollTop =
        window.pageYOffset ||
        document.documentElement.scrollTop ||
        document.body.scrollTop;// 到顶部的滚动距离
      var offsetTop = document.querySelector("#searchBar").offsetTop;//元素到顶部的距离
      console.log(scrollTop,offsetTop)
      if(scrollTop >  offsetTop){
            $(".nav_list").addClass("nav_list2")
      }else if(offsetTop =  0 ){
             $(".nav_list").removeClass("nav_list2")
      }

    }
    //
  }
};
</script>
<style scoped lang="scss">
.nav_list2{
    width: 100%;
    position: fixed;
    top:0;
    z-index:999;
    background: #fff;
}

.host_concat {
  width: 100%;
  height: auto;
  margin-top: 0.5rem;
  .concat_img {
    width: 100%;
    height: 4.8rem;
    position: relative;
    font-size: 0.3rem;
    img {
      width: 100%;
      height: 100%;
    }
    .postion_top {
      position: absolute;
      top: 0.266666rem;
      border-radius: 2rem;
      background: rgba(0, 0, 0, 0.5);
      color: #fff;
      left: 0.266666rem;
      padding: 0.15rem;
      font-size: 0.32rem;
      padding-left: 0.15rem;
    }
    .postion_bottom {
      position: absolute;
      bottom: 0.266666rem;
      display: flex;
      flex-direction: column;
      right: 0.2666666rem;

      .s1 {
        background: #fdc72e;
        color: #fff;
        padding: 0.1rem;
        text-align: center;
      }
      .s2 {
        background: #fff;
        color: #fdc72e;
        padding: 0.1rem;
        text-align: center;
      }
    }
  }
  .concat_text {
    font-size: 0.37rem;
    height: 1.6rem;
    line-height: 0.8rem;
    padding-left: 0.2666666rem;
    .text1 {
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
    .text2 {
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      color: #b4b4b4;
      font-size: 0.32rem;
      span {
        background: #f68b6e;
        color: #fff;
        padding: 0.05rem;
        margin-right: 0.01rem;
        padding-left: 0.15rem;
        padding-right: 0.15rem;
      }
    }
  }
}
.hotcity {
  width: 100%;
  height: auto;
  .hotcity_header {
    width: 100%;
    height: 0.98666666667rem;
    text-align: center;
    background: #f7f7f9;
    i {
      display: inline-block;
      width: 2.1rem;
      height: 0.05rem;
      background: #ededed;
    }
    span {
      font-size: 0.32rem;
      color: #585858;
      background-image: url("~@/assets/images/1.png");
      background-size: 0.43rem 0.43rem;
      padding-left: 0.4rem;
      background-repeat: no-repeat;
    }
  }
  .nev {
    width: 100%;
    height: 1.2rem;
    line-height: 1.2rem;
    display: flex;
    font-size: 0.37rem;
    color: #000;
    border-bottom: solid 0.01rem #585858;

    div {
      width: 25%;
      height: 100%;
      text-align: center;
      position: relative;
      font-weight: 1000;
    }
    :nth-child(1):after {
      content: "";
      position: absolute;
      left: 0;
      bottom: 0;
      width: 100%;
      height: 0.09rem;
      background: #ffc31a;
    }
  }
  //
}
.host_list {
  width: 100%;
  height: auto;
  ul {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    padding-bottom: 0.2666rem;
    li {
      width: 17%;
      height: 0.8rem;
      color: #666;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 0.32rem;
      background: #f7f7f7;
      margin-left: 0.2666rem;
      margin-top: 0.26666rem;
      border-radius: 0.13333rem;
    }
   .moren{
       width: 100%;
    display: flex;
    flex-wrap: wrap;
    padding-bottom: 0.2666rem;
    li {
      width: 17%;
      height: 0.8rem;
      color: #666;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 0.32rem;
      background: #f7f7f7;
      margin-left: 0.2666rem;
      margin-top: 0.26666rem;
      border-radius: 0.13333rem;
    }
   }
    .style_color {
      color: #333;
      -webkit-box-sizing: border-box;
      box-sizing: border-box;
      border: 1px solid #333;
      background: #fdc72e;
      border-radius: 0.13333rem;
    }
  }
}
</style>